//
//  YTAccountSecurityViewController.m
//  YiTuDriverClient
//
//  Created by 石少庸 on 2017/5/22.
//  Copyright © 2017年 Yitu. All rights reserved.
//

#import "YTAccountSecurityViewController.h"
#import "YTValidateIdentityViewController.h"
#import "YTProfileModel.h"

@interface YTAccountSecurityViewController ()
@property (weak, nonatomic) IBOutlet UILabel *depositText;
@property (weak, nonatomic) IBOutlet UILabel *authText;
@property (weak, nonatomic) IBOutlet UILabel *phoneText;
@end

@implementation YTAccountSecurityViewController

- (void)initialize {
    YTProfileModel *model = [YTUtilityManager manager].userModel;
    self.phoneText.text = [NSString stringWithFormat:@"%@****%@", [model.phone substringToIndex:3], [model.phone substringFromIndex:7]];
    self.authText.text = self.authState;
    if ([YTUtilityManager manager].userModel.hasPayPassword == 1) {
        self.depositText.text = @"重置提现密码";
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 0 && indexPath.row == 1) {
        switch ([YTUtilityManager manager].userModel.userRoleNew) {
            case 1:
                [self performSegueWithIdentifier:@"YTDriverAuth" sender:nil];
                break;
            case 2:
                [self performSegueWithIdentifier:@"YTDriverAuthSuccess" sender:nil];
                break;
            case 3:
            case 4:
                [self performSegueWithIdentifier:@"YTDriverAuthWait" sender:nil];
                break;
            case 5:
                [self performSegueWithIdentifier:@"YTDriverAuthFail" sender:nil];
                break;
            case 6:
                break;
            case 7:
                break;
        }
    }
    
    if (indexPath.section == 1 && indexPath.row == 1) {
        if ([YTUtilityManager manager].userModel.hasPayPassword != 1) {
            [self performSegueWithIdentifier:@"YTSetEmbodyPassword" sender:nil];
        } else {
            [self performSegueWithIdentifier:@"YTResetEmbodyPassword" sender:nil];
        }
    }
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"YTSetEmbodyPassword"]) {
        YTValidateIdentityViewController *validate = segue.destinationViewController;
        validate.segueIdentifier = @"YTSetEmbody";
        validate.type = YTEmbodyPasswordSetType;
    }
}

@end
